import { Controller, Post, Body } from '@nestjs/common';
import { DepartmentService } from './department.service';
import { CreateDepartmentDto, FindDepartmentDto, UpdateDepartmentDto, RemoveDepartmentDto, CreateBatchDepartmentDto, RemoveBatchDepartmentDto } from './dto/department.dto';
import { useResult } from '@/common/hooks/useResult';
import { Authority } from '@/common/decorators/authority.decorator';

@Controller('department')
export class DepartmentController {
  constructor(private readonly departmentService: DepartmentService) {}

  @Post('create')
  @Authority()
  async create(@Body() body: CreateDepartmentDto) {
    const res = await this.departmentService.create(body);
    return useResult(res);
  }

  @Post('findAll')
  @Authority()
  async findAll(@Body() body: FindDepartmentDto) {
    const res = await this.departmentService.findAll(body);
    return useResult(res);
  }

  @Post('findOne')
  @Authority()
  async findOne(@Body() body: FindDepartmentDto) {
    const res = await this.departmentService.findOne(body);
    return useResult(res);
  }

  @Post('update')
  @Authority()
  async update(@Body() body: UpdateDepartmentDto) {
    const res = await this.departmentService.update(body);
    return useResult(res);
  }

  @Post('remove')
  @Authority()
  async remove(@Body() body: RemoveDepartmentDto) {
    const res = await this.departmentService.remove(body);
    return useResult(res);
  }

  @Post('removeBatch')
  @Authority()
  async removeBatch(@Body() body: RemoveBatchDepartmentDto) {
    const res = await this.departmentService.removeBatch(body);
    return useResult(res);
  }

  @Post('createBatch')
  @Authority()
  async createBatch(@Body() body: CreateBatchDepartmentDto) {
    const res = await this.departmentService.createBatch(body);
    return useResult(res);
  }
}
